/// <reference path="jquery.min.js" />
/// <reference path="rsseasy.min.js" />
/// <reference path="webviewadapter.min.js" />


//APP配置基本信息
var RssApp = {};
RssApp["WwwHost"] = "http://wang66666.com/";  //线上APP地址
RssApp["ApiHost"] = RssApp.WwwHost + "api/";   //API接口地址
RssApp["UpHost"] = RssApp.WwwHost + "upfile/";
RssApp["AllPage"] = $("section");  //获取所有页
RssApp["CurPage"] = RssApp["AllPage"].first().show();  //默认第一页
RssApp["Menu"] = $("body>footer>a");   //主菜单
RssApp["Width"] = $(window).width();  //APP窗口宽度
RssApp["WinHeight"] = $(window).height();  //APP窗口高度
RssApp["OrderUrl"] = "";  //订单生成接口定义
RssApp["SmsCode"] = "";  //发送的短信验证码
RssApp["ReadyData"] = {};  //当APP启动
RssApp["uiScale"] = 1; //缩放系数
RssApp["getVal"] = function (num) {
    return parseInt(this.uiScale * num * 100);
}
$(window).resize(function () {
    RssApp.Width = $(window).width();
    RssApp.uiScale = RssApp.Width / 750;
    $("html").css("font-size", parseInt(RssApp.uiScale * 100));
}).resize();

//AJAX配置信息
Ajax.prototype.prikey = "www.rsseasy.com";  //数据签名密钥
Ajax.prototype.rss_prikey = "fdsafsa4231fsa@42";  //私钥
Ajax.prototype.host = RssApp["ApiHost"];   //AJAX请求时URL地址相同部份
Ajax.prototype.oncreate = function () {
};
Ajax.onrsscode = function () {}
Ajax.rsscode = function (code) {
    if (Ajax.onrsscode(code))
    {
        Ajax.onrsscode = function () {};
        location.hash = "#loginpassword";
        return;
    }
    RssCode.alert(code);
}

RssTask.synctime(RssApp.ApiHost + "time");  //获取服务器时间接口地址
RssVideo.player = document.getElementById("videoplay");   //指定视频播放器,音乐播放器程序自动创建并在后台调用播放

RssApp["Menu"].click(function () {
    RssApp["Menu"].removeClass();
    $(this).addClass("active");
    JsAdapter.ClearHistory().Submit();
});

//所有单页
var RssPage = {};
RssPage["MaskLayer"] = $("#masklayer");
RssPage.Append = function (pageid) {
    this.page = $(pageid);
    this.header = this.page.find(">header");
    this.title = this.header.find(">h1");
    this.left = this.header.find(".left");
    this.right = this.header.find(".right");
    this.article = this.page.find(">article");
    this.footer = this.page.find(">footer");
};
$("section").each(function ()//通过循环将section增加到RssPage中
{
    var id = this.id;//获取每个section的id值
    if (id) {
        RssPage[id] = new RssPage.Append("#" + id);//此值作为键名
    }
});

//RssEasy.WeiXin.LoginReg();  //微信登录
//RssUser.Update({"myid": 71});   //默认测试帐号ID

//单页切换
window.onhashchange = function () {
    RssApp["AllPage"].hide();
    var hash = location.hash;
    if (hash) {
        RssMusic.stop();
        RssVideo.stop();
        RssApp["Menu"].filter("[href='" + hash + "']").click();//改变footer菜单样式，调用方法：RssApp["Menu"].click()
        document.title = $("#hash header h1").text() || document.title;
        $(hash).show().load();
        return;
    }
    RssApp["AllPage"].first().show().load();
};
window.onhashchange();

if (!Storage.Get("launch")) {
    Storage.Set("launch", "1");
    $("#guidepage").on("pageslideend", function (ev, json) {
        if (json["curpage"] == json["totalpage"]) {
            $(this).hide();
        }
    }).show();
}

JsAdapter.onRollBack = function () {
    history.back();
}
$(function () {
    JsAdapter.Ready({}).Submit();
});


function num(obj) {
    $('input').bind('input propertychange', function () {
        obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
    })
}
function import_price(obj) {
    obj.value = obj.value.replace(/\D/g, '');
    obj.value = obj.value.replace(/^[0]\d*$/, '');
    if (obj.value > 10000000) {
        obj.value = 10000000;
    }
}
//获取验证码
var wait = 60;
function time(o) {
    if (wait == 0) {
        o.removeAttribute("disabled");
        o.value = "获取验证码";
        wait = 60;
    } else {
        o.setAttribute("disabled", true);
        o.value = "重新发送(" + wait + ")";
        wait--;
        setTimeout(function () {
            time(o);
        }, 1000);
    }
}

$("#homepagebanner").on("pageslideend", function (ev, json) {
    $("#homepagebannermin li").removeClass().eq(json['curpage'] - 1).addClass("select");
})
var TransUser = {}
TransUser.Data = {}
TransUser.getKLine = function () { }
var phonereg = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[57])[0-9]{8}$/;


//重写信息


    //显示提示信息
    function remind1(msg, button) {
        $('#remind1 p').text(msg);
        $('#remind1 button').text(button);
        $('.masklayer').show();
        $('#remind1').show();
    }
    //隐藏提示信息
    $('#remind1 button').click(function () {
        $('.masklayer').hide();
        $('#remind1').hide();
        $('#remind1 p').text("");
        $('#remind1 button').text("");
    });    
    //两个按钮提示信息，功能需另写
    function remind2(msg, button1, button2) {
        $('#remind2 p').text(msg);
        $('#remind2 button:nth-child(2)').text(button1);
        $('#remind2 button:nth-child(3)').text(button2);
        $('.masklayer').show();
        $('#remind2').show();
    }
    
RssCode.alert=function (code)
{
    remind1(dictdata.rsscode[code],"确定");
}

//点击屏幕遮罩层消失
$(document).on("click",".masklayer,.loadbox",function(){
    $('.masklayer').hide();
    $('.loadbox').hide();
});